<?php
include 'header.php';
?>
<style type="text/css">
.siderBar dd{ text-align:left !important; cursor:pointer}
.siderBar dd.hasChild{}
.icon{ font-size:16px; color:#006600}
</style>
<div class="pageBox">
  <table width="980" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="220" class="siderBar"><dl>
          <dt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;伙食单位</dt>
          <?php foreach($departmentList as $item):?>
          <dd level="<?php echo $item['level'];?>" rel="<?php echo $item['id'];?>" parent="<?php echo $item['pid'];?>"><?php echo str_repeat('&nbsp;&nbsp;', $item['level']);?><span class="icon">+</span>&nbsp;<a href="/department/show?id=<?php echo $item['id'];?>" target="departmentInfo"><?php echo $item['name'];?></a></dd>
        <?php endforeach;?>
      </dl></td>
      <td width="20"></td>
      <td width="740" class="catalogBox">
      <iframe src="/department/recommend" id="departmentInfo" name="departmentInfo" scrolling="no" onload="iFrameHeight()" frameborder="0" width="100%" height="auto">
      
      </iframe>
      </td>
    </tr>
  </table>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$('.siderBar').find("dd").each(function(index, item){
		var id = $(this).attr('rel');
		var length = $(this).nextAll("dd[parent='"+id+"']").length;
		if(length){
			$(this).find('span').html('+');
			$(this).find('a').attr('href', 'javascript:void(0);');
		}else{
			$(this).find('span').html('-');
		}
	});
	$('.siderBar').find("dd").hide();
	$('.siderBar').find("dd[level='1']").show();
	
	
	$('dd').live('click', function(){
		var id = $(this).attr('rel');
		if($(this).hasClass('open')){
			if($(this).nextAll("dd[parent='"+id+"']").length){
				$(this).find('span').html('+');
				$(this).removeClass('open');
				hide(id);
			}
		}else{
			$(this).find('span').html('-');
			$(this).addClass('open');
			$(this).nextAll("dd[parent="+id+"]").show();
		}
	});
});


function hide(id){
	$("dd[parent="+id+"]").hide();
	if($("dd[parent="+id+"]").length){
		$("dd[rel="+id+"]").find('span').html('+');
		$("dd[parent="+id+"]").each(function(index, item){
			hide($(this).attr('rel'));
		});
	}
}

function iFrameHeight() {   

		var ifm= document.getElementById("departmentInfo");   

		var subWeb = document.frames ? document.frames["departmentInfo"].document : ifm.contentDocument;   

		if(ifm != null && subWeb != null) {

		   ifm.height = subWeb.body.scrollHeight;

		}   

	}  
</script>

<?php 
include 'footer.php';
?>